

#ifndef _UCSSGETFILTER_H
#define _UCSSGETFILTER_H

class UcApDocument;

class UcEdSelectionSetService
{
public:

    virtual Ucad::ErrorStatus ssNameX(
        bool bIsSubSelectionIndex,
    	int index,
        resbuf*& result) = 0;

    virtual Ucad::ErrorStatus ssNameSubentityX(
        bool bIsSubSelectionIndex,
        int index,
        int subentityIndex,
        resbuf*& result) = 0;

    virtual Ucad::ErrorStatus ssNameSubentities(
        bool bIsSubSelectionIndex,
        int index,
        UcDbFullSubentPathArray& subEntities) = 0;

    virtual Ucad::ErrorStatus add(
        resbuf *ssnameXList,
        const UcDbFullSubentPath *pPath = NULL,
        const UcDbObjectId* pEntselSubent = NULL) = 0;

    virtual Ucad::ErrorStatus addSubentity(
        resbuf *ssnameXList,
        const UcDbFullSubentPath& subEntity) = 0;

    virtual Ucad::ErrorStatus remove(
        int index) = 0;

    virtual Ucad::ErrorStatus removeSubentity(
        int entityIndex,
        int subEntityIndex) = 0;

    virtual Ucad::ErrorStatus highlight(
    	int subSelectionIndex,
        const UcDbFullSubentPath& path) = 0;

	virtual int subSelectionMode() = 0;

	virtual Ucad::ErrorStatus getSubSelectionPoints(UcGePoint3dArray& points) = 0;

	virtual Ucad::ErrorStatus add(const UcArray<resbuf*>& ssnameXList,	const UcArray<UcDbFullSubentPath *> *pPath,	bool bAddsAreUnique) = 0;

	virtual Ucad::ErrorStatus addSubentities(resbuf* ssnameXList, const UcArray<UcDbFullSubentPath>& subEntities, bool bAddsAreUnique) = 0;

	virtual Ucad::ErrorStatus remove(const UcArray<int>& indices) = 0;

	virtual Ucad::ErrorStatus removeSubentities(int entityIndex, const UcArray<int>& subEntityIndices) = 0;
};

typedef UcArray<UcDbIntArray, UcArrayObjectCopyReallocator<UcDbIntArray> >
    UcDbArrayIntArray;

class UcEdSSGetFilter: public UcEdInputContextReactor
{
public:

    virtual void
    ssgetAddFilter(
	    int ssgetFlags,
	    UcEdSelectionSetService &service,
	    const UcDbObjectIdArray& selectionSet,
	    const UcDbObjectIdArray& subSelectionSet)
    {  }

    virtual void
    ssgetRemoveFilter(
	    int ssgetFlags,
	    UcEdSelectionSetService &service,
	    const UcDbObjectIdArray& selectionSet,
	    const UcDbObjectIdArray& subSelectionSet,
        UcDbIntArray& removeIndexes,
        UcDbArrayIntArray& removeSubentIndexes)
    {  }

    virtual void
    ssgetAddFailed(
	    int ssgetFlags,
	    int ssgetMode,
	    UcEdSelectionSetService &service,
	    const UcDbObjectIdArray& selectionSet,
        resbuf *rbPoints)
    {  }

    virtual void
    ssgetRemoveFailed(
	    int ssgetFlags,
	    int ssgetMode,
	    UcEdSelectionSetService &service,
	    const UcDbObjectIdArray& selectionSet,
	    resbuf *rbPoints,
        UcDbIntArray& removeIndexes,
        UcDbArrayIntArray& removeSubentIndexes)
    {  }

    virtual void
    endSSGet(
	    Ucad::PromptStatus returnStatus,
	    int ssgetFlags,
	    UcEdSelectionSetService &service,
	    const UcDbObjectIdArray& selectionSet)
    {  }

    virtual void
    endEntsel(
        Ucad::PromptStatus       returnStatus,
        const UcDbObjectId&      pickedEntity,
        const UcGePoint3d&       pickedPoint,
        UcEdSelectionSetService& service)
    {  }
};

Ucad::ErrorStatus addSSgetFilterInputContextReactor(
                        UcApDocument *pDoc, UcEdSSGetFilter *pFilter);

Ucad::ErrorStatus removeSSgetFilterInputContextReactor(
                        UcApDocument *pDoc, UcEdSSGetFilter *pFilter);

Ucad::ErrorStatus setAllowDuplicateSelection(
                        UcApDocument *pDoc, ZSoft::Boolean flag);

bool              duplicateSelectionsAllowed(UcApDocument *pDoc);

namespace UcEdSSGet {

enum UcEdSSGetFlags {
    kNormal         =  0,
    kPickPoints     =  1,
    kDuplicates     =  2,
    kNestedEntities =  4,
    kSubEntities    =  8,
    kSinglePick     = 16,
    kPickfirstSet   = 32,
    kPreviousSet    =  64,
    kSubSelection   = 128,
	kUndo           = 256,
	kFailedPickAuto = 512,
	kCommandPreview = 1024,
	kAllViewports   = 2048,
	kForBoxPick     = 4096,
	kPreSelectionHilite = 8192,
};

enum UcEdSSGetModes {
    kWin = 1,   
    kCross,     
    kBox,       
    kLast,      
    kEntity,    
    kAll,       
    kFence,     
    kCPoly,     
    kWPoly,     
    kPick,      
    kEvery,     
    kXten,      
    kGroup,     
    kPrevious,
	kMultiple,
};

};

class UcEdSSGetFilter2 : public UcEdSSGetFilter
{
public:

    virtual void
    ssgetRolloverFilter(
        const UcDbFullSubentPath &subEntityPath,
        UcDbFullSubentPath &highlightPath)
    {  }
};

Ucad::ErrorStatus addSSgetFilterInputContextReactor(
                        UcApDocument *pDoc, UcEdSSGetFilter2 *pFilter);

Ucad::ErrorStatus removeSSgetFilterInputContextReactor(
                        UcApDocument *pDoc, UcEdSSGetFilter2 *pFilter);

class UcEdSSGetFilter3 : public UcEdSSGetFilter
{
public:

    virtual void
    ssgetRolloverFilter(
        const UcDbFullSubentPath &subEntityPath,
        UcDbFullSubentPathArray &highlightPaths)
    {  }
};

Ucad::ErrorStatus addSSgetFilterInputContextReactor(
    UcApDocument *pDoc, UcEdSSGetFilter3 *pFilter);
Ucad::ErrorStatus removeSSgetFilterInputContextReactor(
    UcApDocument *pDoc, UcEdSSGetFilter3 *pFilter);

class UcEdSubSelectFilterService
{
public:

    virtual Ucad::ErrorStatus ssNameX(
        bool bIsSubSelectionIndex,
        int index,
        resbuf*& result) = 0;

    virtual Ucad::ErrorStatus add(
        resbuf *ssnameXList,
        const UcDbFullSubentPath& path) = 0;

    virtual Ucad::ErrorStatus remove(
        bool bIsSubSelectionIndex,
        int index) = 0;
};

class UcEdSSGetSubSelectFilter : public UcEdInputContextReactor
{
public:

    virtual Ucad::ErrorStatus
        getSubentPathsAtGsMarker(
            UcDbEntity*                    pEnt,
            bool                           bAdding,
            const UcDbFullSubentPathArray& selectedPaths,
            UcDb::SubentType               type,
            ZSoft::GsMarker                gsMark,
            const UcGePoint3d&             pickPoint,
            const UcGeMatrix3d&            viewXForm,
            int&                           numPaths,
            UcDbFullSubentPath*&           subentPaths,
            int                            numInserts,
            UcDbObjectId*                  entAndInsertStack) = 0;

    virtual Ucad::ErrorStatus
        subSelectClassList(UcArray<UcRxClass*>& classes) = 0;

    virtual void
        ssgetAddFilter(
            int                            ssgetFlags,
            UcEdSubSelectFilterService&    service,
            const UcDbObjectId&            object,
            const UcDbFullSubentPathArray& selectedPaths,
            const UcDbFullSubentPathArray& addedPaths) = 0;

    virtual void
        ssgetRemoveFilter(
            int                            ssgetFlags,
            UcEdSubSelectFilterService&    service,
            const UcDbObjectId&            object,
            const UcDbFullSubentPathArray& selectedPaths,
            const UcDbFullSubentPathArray& removedPaths) = 0;
};

Ucad::ErrorStatus addSSgetFilterInputContextReactor(
                        UcApDocument             *pDoc,
                        UcEdSSGetSubSelectFilter *pFilter);

Ucad::ErrorStatus removeSSgetFilterInputContextReactor(
                        UcApDocument             *pDoc,
                        UcEdSSGetSubSelectFilter *pFilter);

#endif  

